package com.example.wechat.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.wechat.R;

public class CommentDialog extends Dialog {
    private EditText commentEditText;
    private OnCommentSubmitListener listener;

    public interface OnCommentSubmitListener {
        void onCommentSubmit(String comment);
    }

    public CommentDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_comment);

        commentEditText = findViewById(R.id.comment_edit_text);
        TextView cancelButton = findViewById(R.id.cancel_button);
        TextView confirmButton = findViewById(R.id.confirm_button);

        cancelButton.setOnClickListener(v -> dismiss());

        confirmButton.setOnClickListener(v -> {
            String comment = commentEditText.getText().toString().trim();
            if (!comment.isEmpty() && listener != null) {
                listener.onCommentSubmit(comment);
                dismiss();
            }
        });
    }

    public void setOnCommentSubmitListener(OnCommentSubmitListener listener) {
        this.listener = listener;
    }
} 